<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">职位</label>
        <div class="layui-input-block">
            <input type="text" name="position" lay-verify="required" lay-reqtext="职位不能为空" placeholder="请输入职位" value="" class="layui-input">
            <tip>填写自己管理账号的职位。</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">薪资</label>
        <div class="layui-input-block">
            <input type="number" name="wage" lay-verify="required" lay-reqtext="薪资不能为空" placeholder="请输入薪资" value="" class="layui-input">
            <tip>填写薪资为：xx元/天。</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">公司</label>
        <div class="layui-input-block">
            <input type="text" name="company" lay-verify="required" lay-reqtext="公司不能为空" placeholder="请输入公司名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">电话</label>
        <div class="layui-input-block">
            <input type="number" name="telephone" lay-verify="required" lay-reqtext="电话不能为空" placeholder="请输入联系方式" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">地区</label>
        <div class="layui-input-block">
            <input type="text" name="region" lay-verify="required" lay-reqtext="地区不能为空" placeholder="请输入工作所在地区" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">截止日期</label>
        <div class="layui-input-block">
            <input type="text" name="deadtime" id="date" lay-verify="datetime" placeholder="yyyy-MM-dd HH:mm:ss"
                   autocomplete="off" class="laydate">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">工作时间</label>
        <div class="layui-input-block">
            <input type="text" name="worktime" id="date" lay-verify="datetime" placeholder="yyyy-MM-dd HH:mm:ss"
                   autocomplete="off" class="laydate">
        </div>
    </div>
   
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">工作内容</label>
        <div class="layui-input-block">
            <textarea name="description" class="layui-textarea" placeholder="请输入备注信息"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>


<script>
    layui.use(['form','element'], function () {
      // 表单对象  form
      var form = layui.form
            //jquery 对象 $
            , $ = layui.jquery
            ,element = layui.element
            
            // 日期组件
            , laydate = layui.laydate;

        //日期   渲染上面 id 为 date 的 标签

        //日期插件
            $(".laydate").each(function(){
                laydate.render({
                elem: this, //指定元素  表示当前的元素
                type: 'datetime', //date日期  time时间  year年  month月份  
                });
            })


        // laydate.render({
        //     elem: '#date','#date1'
        //     ,type: 'datetime'
        // });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                "url":"http://localhost:8080/parttimeday/insertparttimeday",
               // "headers":{"token":token},
                "data": data.field,
                // result 参数 表式后台响应的数据
                "success":function(result){
                    var str =  JSON.stringify(result);
                    // console.log("----------------"+str);
                    if(result.code == 200){

                       // 关闭 弹出层
                       var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.msg("添加成功");
                        parent.layer.close(iframeIndex);

                    }else{
                        layer.msg(result.msg);
                    }
                },
                "dataType":"json"
            });

            return false;
        });

    });
</script>
</body>
</html>